﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Model
{
    public class ActivityCategoryRepository
    {
        private JzSportDbContext _dbContext;

        public ActivityCategoryRepository(JzSportDbContext dbContext)
        {
            _dbContext = dbContext;
        }

        public ActivityCategory Get(string code)
        {
            return _dbContext.Set<ActivityCategory>().Where(p => p.Code == code).SingleOrDefault();
        }

        public void Create(ActivityCategory category)
        {
            _dbContext.Set<ActivityCategory>().Add(category);
        }

        public void Update(ActivityCategory category)
        {
            _dbContext.Entry<ActivityCategory>(category).State = System.Data.EntityState.Modified;
        }

        public List<ActivityCategory> GetAll()
        {
            return _dbContext.Set<ActivityCategory>().ToList();
        }
    }
}
